package com.spzx.product.api;


import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.constant.ServiceNameConstants;
import com.spzx.common.core.domain.R;
import com.spzx.product.api.factory.RemoteProductFallbackFactory;

import com.spzx.product.api.vo.ProductSkuVo;
import com.spzx.product.api.vo.SkuPriceVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@FeignClient(
        contextId = "remoteProductService",//用于给 Feign 客户端指定一个唯一的上下文 ID
        value = ServiceNameConstants.PRODUCT_SERVICE,// Feign 客户端要调用的服务名称
        fallbackFactory = RemoteProductFallbackFactory.class// 用于指定一个回退工厂类，当远程服务调用失败时，会使用该回退工厂类来创建备用客户端
)
public interface RemoteProductService {

    @GetMapping("/productSku/getProductSku/{skuId}")
    R<ProductSkuVo> getProductVoSku(
            @PathVariable("skuId") Long skuId,
            @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
    //@RequestHeader : 自定义请求头 key value 对应 SecurityConstants.FROM_SOURCE

    @GetMapping(value = "/productSku/getSkuPrice/{skuId}")
    R<SkuPriceVo> getSkuPrice(
            @PathVariable("skuId") Long skuId,
            @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping(value = "/productSku/getSkuPriceList")
    R<List<SkuPriceVo>> getSkuPriceList(
            @RequestBody List<Long> skuIdList,
            @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
